#ifndef __CPPTUTORCONCRETESUBJECTCLOCKTIMER_H__
#define __CPPTUTORCONCRETESUBJECTCLOCKTIMER_H__

#include "cppTutorObserver.h" // include parent class definition
#include "cppTutorSubject.h"

// include files used to obtain the current system time
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <string.h>

//=========================================================
// ConcreteSubject class
//
// ClockTimer
//
// It is a ConcreteSubject class and is a child class of
// the Subject class.
//
// It is a time observer. Whenever member function Tick()
// is called. It obtains the current system
// time and store it as a character string. It called
// the update function for all of its observer objects.
//
//=========================================================

class ClockTimer : public Subject 
{
    public:
        ClockTimer() 
        {
            #ifdef WIN32
            _strtime ( tmpbuf );  // tmpbuf = current system time
            #else
            strtime ();
            #endif
        }; 
        
        int GetHour();  // get hour (used by observer)
        int GetMinute(); // get minute (used by observer)
        int GetSecond(); // get second (used by observer)

        void Tick();  // obtian system time (change state)
        #ifndef WIN32
            inline void strtime ();
        #endif
        
    private:
        char tmpbuf[128]; // store system time
};

#endif //__CPPTUTORCONCRETESUBJECTCLOCKTIMER_H__
